package com.shenyun.mapper;

import com.shenyun.pojo.Student;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper
public interface StudentMapper {

    //查询学生数据
    @Select("select * from student")
    List<Student> queryStudents();

    //查询学生信息 学号
    @Select("SELECT * FROM student WHERE number = #{number}")
    List<Student> queryStudentById(@Param("number") Integer number);

    //更新学生信息
    @Update("UPDATE student SET name=#{name}, grade=#{grade}, " +
            "clbum=#{clbum}, gender=#{gender}, age=#{age} WHERE number=#{number}")
    void updateStudentInfo(@Param("number") Integer number, @Param("name") String name,
                           @Param("grade") String grade, @Param("clbum") String clbum,
                           @Param("gender") String gender, @Param("age") Integer age);

    //新增学生信息
    @Insert("INSERT INTO student (number, name, grade, clbum, gender, age) VALUES (#{number}, #{name}, #{grade}, #{clbum}, #{gender}, #{age})")
    void insertStudent(@Param("number") Integer number, @Param("name") String name,
                       @Param("grade") String grade, @Param("clbum") String clbum,
                       @Param("gender") String gender, @Param("age") Integer age);

    //删除学生信息
    @Delete("DELETE FROM Student WHERE number = #{number}")
    void deleteStudent(Integer number);
}
